/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projetweb.modeles;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author mankou
 */
@Entity
public class Client implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    private String firstname;
    private String lastname;
    private String login;
    private String pass;
    private String adress;
    @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.EAGER,mappedBy="client")
    private Collection<Commande> commande ;
    @OneToOne(cascade={CascadeType.PERSIST})
    private Affiche affiche;

    public Client() {
    }

    public Client(final String firstname,final String lastname, final String login,final String pass, final String adress) throws UnsupportedEncodingException {
        this.firstname = firstname;
        this.lastname = lastname;
        this.login = login;
        this.pass = pass;
        this.adress = adress;
    }
    
    

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getAdress() {
        return adress;
    }

    public void setAdress(String adress) {
        this.adress = adress;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public Collection<Commande> getCommande() {
        return commande;
    }

    public void setCommande(Collection<Commande> commande) {
        this.commande = commande;
    }

    public Affiche getAffiche() {
        return affiche;
    }

    public void setAffiche(Affiche affiche) {
        this.affiche = affiche;
    }
    
    
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) id;
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Client)) {
            return false;
        }
        Client other = (Client) object;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "projetweb.Client[ id=" + id + " ]";
    }
    
}
